
<link rel="stylesheet" href="jquery/easyui/themes/default/easyui.css">
<link rel="stylesheet" href="jquery/easyui/themes/icon.css">
<body>
<div style="width: 100%;height: 98%">
	<input class="easyui-searchbox" data-options="prompt:'请输入',menu:'#mm',searcher:doSearch" style="width:300px"></input>
	<div id="mm">
		<div data-options="name:'order_p_order_no_comp'">订单编号</div>
		<div data-options="name:'order_p_product_no'">工厂型号</div>
		<div data-options="name:'order_p_version_no'">客户型号</div>
		<div data-options="name:'order_p_order_no'">系统订单编号</div>
	</div>
    <table id="easyui_datagrid_source_fac" style="border:1px solid blue" >

    </table>
</div>


<script src="https://upload.shinehao.com.cn/20180816150739jquery-1.8.3.min.js"></script>
<script src="https://upload.shinehao.com.cn/20180816145716jquery.easyui.min.js"></script>
<script src="https://upload.shinehao.com.cn/20180816151727easyui-lang-zh_CN.js"></script>
<script>
function loaddata(name,value){
	$('#easyui_datagrid_source_fac').datagrid({
        url:window.parent.serverUrl+"/createOrder/getOrderInfoByParam",
        queryParams: {
            name:name,
            value:value
        },
        columns:[[
            {field:'order_p_order_no',title:'系统订单编号'},
            {field:'order_p_order_no_comp',title:'订单编号'},
            {field:'order_p_product_no',title:'工厂型号'},
            {field:'order_p_version_no',title:'客户型号'}
        ]],
        height:"90%",
        width:"100%",
        //panelWidth:"100%",
        //panelHeight:"88%",
        //rownumbers:true,
        fitColumns:true,
        pagination:false,
        loadMsg:"加载中,请等待...",
        singleSelect:true,
        align:"center",
        //toolbar: '#easyui_datagrid_source_fac_tool',
        loadFilter: function(data){
          return data.data;  
        },onSelect:function(index,row){
        	$.messager.progress({title:'请等待',msg:'<span style="color:green">数据填充中...</span>'});
        	loadSourceColresizeTableAndFill(row.order_p_order_no,null);
        }
    });
}
/*修正物料组件 source_factory_colresizeable*/
function loadSourceColresizeTable(table_source_arr,table_source_arr_str,table_source_line_total,table_source_arr_for_two,table_source_arr_str_for_two,table_source_line_total_for_two){
	//source_factory_colresizeable_for_two
	localStorage.setItem("temp_info_table_source_arr",table_source_arr);
	localStorage.setItem("temp_info_table_source_arr_str",table_source_arr_str);
	localStorage.setItem("table_source_line_total",table_source_line_total);
	localStorage.setItem("temp_info_table_source_arr_for_two",table_source_arr_for_two);
	localStorage.setItem("temp_info_table_source_arr_str_for_two",table_source_arr_str_for_two);
	localStorage.setItem("table_source_line_total_for_two",table_source_line_total_for_two);
	console.info(table_source_arr);
	console.info(table_source_arr_str);
	console.info(table_source_line_total);
	console.info(table_source_arr_for_two);
	console.info(table_source_arr_str_for_two);
	console.info(table_source_line_total_for_two);
    //删除所有物料 并且保留行只有一行
    $(".source_factory_colresizeable",parent.document).find("input:button").each(function(){
        if($(this).val()=="删除列"){
            $(this).click();
        }
    })
    $(".source_factory_colresizeable",parent.document).find("input:button").each(function(index,el){
        if($(this).val()=="删除行"){
            $(this).click();
        }
    })
    //删除所有物料 并且保留行只有一行
    $(".source_factory_colresizeable_for_two",parent.document).find("input:button").each(function(){
        if($(this).val()=="删除列"){
            $(this).click();
        }
    })
    $(".source_factory_colresizeable_for_two",parent.document).find("input:button").each(function(index,el){
        if($(this).val()=="删除行"){
            $(this).click();
        }
    })
    //增加一行避免获取不到name 无需 因为默认保留一行
    //window.parent.tbsourcefactoryColresizeEvent.source_factory_add_x();
    //增加列
    var table_source_arr_Arr=table_source_arr.split(",");
    table_source_arr_str=eval(table_source_arr_str);
    for(var i=0;i<table_source_arr_Arr.length;i++){//有几个物料
    	localStorage.setItem("table_source_factory_colresize.html",JSON.stringify({name:"html_name_null",text:"materialType",special_val:2}));
        //增加列
        if(table_source_arr_Arr[i]==1
        		&&(table_source_arr_str[i][0]=="order_s_material_model"
        				||table_source_arr_str[i][0]=="order_s_feed_total"
        				||table_source_arr_str[i][0]=="order_s_order_total")){
        	//alert(table_source_arr_str[i][0]);
        	localStorage.setItem("table_source_factory_colresize.html",JSON.stringify({name:"html_name_null",text:"materialType",special_val:100}));
            //假数据 排除订单数投料数 特定
            if(table_source_arr_str[i][0]=="order_s_feed_total"){
            	localStorage.setItem("table_source_factory_colresize.html",JSON.stringify({name:"html_name_null",text:"投料数",special_val:100}));
            }
            if(table_source_arr_str[i][0]=="order_s_order_total"){
            	localStorage.setItem("table_source_factory_colresize.html",JSON.stringify({name:"html_name_null",text:"订单数",special_val:100}));                
            }
            /*单列情况*/
             window.parent.tbsourcefactoryColresizeEvent.source_factory_add_y(100,1);
             continue;//不用增加子列
            /*单列情况结束*/
        }else{
        	if(table_source_arr_Arr[i]==1&&table_source_arr_str[i][0]=="order_s_dh_total"){//大货数量
            	localStorage.setItem("table_source_factory_colresize.html",JSON.stringify({name:"html_name_null",text:"大货",special_val:2,"domName":"special_dh_date"}));
            	window.parent.tbsourcefactoryColresizeEvent.source_factory_add_y(2,1);
            	continue;
        	}
            window.parent.tbsourcefactoryColresizeEvent.source_factory_add_y(2,1);
        }
        var uniqueId = window.parent.tbsourcefactoryColresizeEvent.last_uniqueId_for_template_card;
        var data=[];
        for(var j=0;j<table_source_arr_str[i].length;j++){//每个物料增加几个小列
        	//alert(table_source_arr_str[i][j]);
            data.push({"html_name":table_source_arr_str[i][j],"text":window.parent.basic_index_card.nametotext[table_source_arr_str[i][j]]})
        }
        window.parent.tbsourcefactoryColresizeEvent.add_y_byuniqueId(uniqueId,table_source_arr_str[i].length,data);
    }
    //删除初始行的小列
    $(".source_factory_colresizeable",parent.document).find("[btn_source_del_s_y_for_template_card]").each(function(){
        $(this).click();
    })
    //增加行
    for(var i=0;i<table_source_line_total-1;i++){
        window.parent.tbsourcefactoryColresizeEvent.source_factory_add_x();
    }
    console.info("---------------------------------------------------")
	$('[td_uniqueid="undefined"]',parent.document).remove();
    
    /* 物料大组件二 */
    //增加一行避免获取不到name 无需 因为默认保留一行
    //window.parent.tbsourcefactoryColresizeEvent.source_factory_add_x();
    //增加列
    if(!table_source_arr_for_two){
    	return;
    }
    var table_source_arr_Arr=table_source_arr_for_two.split(",");
    table_source_arr_str=eval(table_source_arr_str_for_two);
    for(var i=0;i<table_source_arr_Arr.length;i++){//有几个物料
    	localStorage.setItem("table_source_factory_colresize_for_two.html",JSON.stringify({name:"html_name_null",text:"materialType",special_val:2}));
        //增加列
        if(table_source_arr_Arr[i]==1
        		&&(table_source_arr_str[i][0]=="order_s_material_model"
        				||table_source_arr_str[i][0]=="order_s_feed_total"
        				||table_source_arr_str[i][0]=="order_s_order_total")){
        	//alert(table_source_arr_str[i][0]);
        	localStorage.setItem("table_source_factory_colresize_for_two.html",JSON.stringify({name:"html_name_null",text:"materialType",special_val:100}));
            //假数据 排除订单数投料数 特定
            if(table_source_arr_str[i][0]=="order_s_feed_total"){
            	localStorage.setItem("table_source_factory_colresize_for_two.html",JSON.stringify({name:"html_name_null",text:"投料数",special_val:100}));
            }
            if(table_source_arr_str[i][0]=="order_s_order_total"){
            	localStorage.setItem("table_source_factory_colresize_for_two.html",JSON.stringify({name:"html_name_null",text:"订单数",special_val:100}));                
            }
            /*单列情况*/
             window.parent.tbsourcefactoryColresizeEventForTwo.source_factory_add_y(100,1);
             continue;//不用增加子列
            /*单列情况结束*/
        }else{
        	if(table_source_arr_Arr[i]==1&&table_source_arr_str[i][0]=="order_s_dh_total"){//大货数量
            	localStorage.setItem("table_source_factory_colresize_for_two.html",JSON.stringify({name:"html_name_null",text:"大货",special_val:2,"domName":"special_dh_date"}));
            	window.parent.tbsourcefactoryColresizeEventForTwo.source_factory_add_y(2,1);
            	continue;
        	}
            window.parent.tbsourcefactoryColresizeEventForTwo.source_factory_add_y(2,1);
        }
        var uniqueId = window.parent.tbsourcefactoryColresizeEventForTwo.last_uniqueId_for_template_card;
        var data=[];
        for(j=0;j<table_source_arr_str[i].length;j++){//每个物料增加几个小列
        	//alert(table_source_arr_str[i][j]);
            data.push({"html_name":table_source_arr_str[i][j],"text":window.parent.basic_index_card.nametotext[table_source_arr_str[i][j]]})
        }
        window.parent.tbsourcefactoryColresizeEventForTwo.add_y_byuniqueId(uniqueId,table_source_arr_str[i].length,data);
    }
    //删除初始行的小列
    $(".source_factory_colresizeable_for_two",parent.document).find("[btn_source_del_s_y_for_template_card]").each(function(){
        $(this).click();
    })
    //增加行 行数相同 避免重复
    /* for(var i=0;i<table_source_line_total-1;i++){
        window.parent.tbsourcefactoryColresizeEventForTwo.source_factory_add_x();
    } */
    console.info("---------------------------------------------------")
	$('[td_uniqueid="undefined"]',parent.document).remove();
    
}
/*载入数据*/
function loadSourceColresizeTableAndFill(order_no,data_form){
	window.parent.basic_index_card.data_form=data_form;
    $.ajax({
          type: 'POST',
          url: window.parent.serverUrl+"/createOrder/getTemplateInfoByOrderNo",
          data: {"order_no":order_no},
          success: function(data){
        	console.info(data);
        	if(data.data==null){
        		alert("当前订单没有模版数据,不支持载入数据");
        		window.parent.basic_index_card.destroydialog();
        		$.messager.progress('close');
        		return;
        	}
            //修正物料组件
            loadSourceColresizeTable(data.data.table_source_arr,data.data.table_source_arr_str,data.data.table_source_line_total,
            		data.data.table_source_arr_for_two,data.data.table_source_arr_str_for_two,data.data.table_source_line_total_for_two);
            //填充数据
            console.info("$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$")
            //获取数据
        	$.ajax({
                type: 'POST',
                url: window.parent.serverUrl+"/createOrder/getOrderInfoForTemp",
                data: {"order_no":order_no,
                	"sort_order_s_input_material_type":"sort",
                	"order_s_input_material_house":$('[name="order_s_input_material_house"]',parent.document).map(function(){return $(this).val()}).get().join(","),
                	"order_s_input_material_type":$('[name="order_s_input_material_type"]',parent.document).map(function(){return $(this).text()}).get().join(","),
                	"order_s_table_source_arr_str":window.parent.basic_index_card.getBigMaterialDataByOrder()["order_s_table_source_arr_str"]
                },
                success: function(data){
                  window.parent.basicDataFixed.order_no=order_no;
                  //载入数据
                  setTimeout(function(){
                  	window.parent.myformUtils.formFillByAllNames("#myformsubmit",data.data);
                  	window.parent.tbsourcefactoryColresizeEvent.sumFeedTotalByMaterialType($("[name='order_p_product_work_no'] option:selected",parent.document).attr("processingobject"));
                  	window.parent.table_order_info.reloadQrcode();
                    window.parent.basic_index_card.destroydialog();
                    $.messager.progress('close');
      			  }, 2000);
                }
        	});
          }
    });
    
}
function doSearch(value,name){
			//alert('You input: ' + value+'('+name+')');
			if(value.trim().length>0){
                loaddata(name.trim(),value.trim());
                //loadSourceColresizeTable
			}else{
				alert("务必输入查询参数");
			}
		}
</script>
</body>


























